import 'package:flutter/foundation.dart';

class Http {
  static List<Function> reg = [];
  getDate(Function(String data) fun) {
    reg.add(fun);
  }

  void __invoke(msg) {
    int i = 1;
    while (true) {
      bool st = true;
      Future.delayed(Duration(seconds: 5 * i), () {
        if (!reg.isEmpty) {
          if (st) {
            reg[0]('[{"url": "img/d.jpg","name": "测试"}]');
          } else {
            reg[0](
                '[{"url": "img/d.jpg","name": "测试"},{"url": "img/y.jpg","name": "测试1"}]');
          }
        }
        st = !st;
      });
      i++;
    }
  }

  Future<void> starts() async {
    final result = await compute(__invoke, "");
  }

  Future<void> start() async {
    Future.delayed(Duration(seconds: 5), () {
      starts();
    });
  }
}
